import { getComponent } from "./utils"
import locales from './locales/index';
import registerLocales from "./utils/registerLocales";
registerLocales(locales)

const componentContext =  require['context']('../components', true, /\.((\/[a-zA-Z0-9]+){3}|(\/[a-zA-Z0-9]+){2}(\/SyncComponents)(\/[a-zA-Z0-9]+))\/(designer|preview)\/(web\/index\.ts(x?)|schema.ts(x?))$/i)
export function getComponents() {
    return getComponent(componentContext, 'web')
}

export * as decorator from '@common/decorator/web'


// 注册设计器多语言
const localeContext =  require['context']('../components', true, /\.((\/[a-zA-Z0-9]+){3}|(\/[a-zA-Z0-9]+){2}(\/SyncComponents)(\/[a-zA-Z0-9]+))\/designer\/(locale\.ts(x?))$/i)
const localeData = {};
localeContext.keys().forEach(path => {
    const data = localeContext(path)
    Object.assign(localeData, data)
});
registerLocales(localeData)
